<template>
	<view class="bj" v-if="data?.driver_pick_data || data?.user_dispatch_data || data?.driver_delivery_data">
		<template v-if="data.driver_pick_data">
			<view class="top-text">
				<view class="text">
					司机取件记录
				</view>
				<view class="time">
					{{ data.driver_pick_data.time }}
				</view>
			</view>
			<view class="images">
				<image :src="item" @click="handlePreviewImage(data.driver_pick_data.img,index)"
					v-for="(item, index) in data.driver_pick_data.img" :key="index"></image>
				<view class="i"></view>
			</view>
		</template>
		<template v-if="data.user_dispatch_data">
			<view class="top-text">
				<view class="text">
					用户寄件记录
				</view>
				<view class="time">
					{{ data.user_dispatch_data.time }}
				</view>
			</view>
			<view class="images">
				<image :src="item" @click="handlePreviewImage(data.user_dispatch_data.img,index)"
					v-for="(item, index) in data.user_dispatch_data.img" :key="index"></image>
				<view class="i"></view>
			</view>
		</template>
		<template v-if="data.driver_delivery_data">
			<view class="top-text">
				<view class="text">
					司机送达记录
				</view>
				<view class="time">
					{{ data.driver_delivery_data.time }}
				</view>
			</view>
			<view class="images">
				<image :src="item" @click="handlePreviewImage(data.driver_delivery_data.img,index)"
					v-for="(item, index) in data.driver_delivery_data.img" :key="index"></image>
				<view class="i"></view>
			</view>
		</template>
	</view>
</template>

<script setup>
	const props = defineProps({
		data: {
			type: Object,
			default: () => {}
		}
	})
	// 预览图片
	const handlePreviewImage = (images, index) => {
		// 预览图片
		uni.previewImage({
			urls: images,
			current: index,
			longPressActions: {
				itemList: ['发送给朋友', '保存图片', '收藏'],
				success: function(data) {
					console.log('选中了第' + (data.tapIndex + 1) + '个按钮,第' + (data.index + 1) + '张图片');
				},
				fail: function(err) {
					console.log(err.errMsg);
				}
			}
		});
	}
</script>

<style lang="scss" scoped>
	.bj {
		background: #fff;
		box-shadow: 0rpx 8rpx 16rpx 0rpx rgba(128, 128, 128, 0.06);
		border-radius: 32rpx;
		padding: 26rpx;
		margin-top: 18rpx;

		.top-text {
			display: flex;
			align-items: center;
			justify-content: space-between;

			.text {
				font-family: PingFang SC, PingFang SC;
				font-weight: 400;
				font-size: 24rpx;
				color: #2C1F21;
				line-height: 28rpx;
			}

			.time {
				font-family: PingFang SC, PingFang SC;
				font-weight: 400;
				font-size: 24rpx;
				color: #A6A1A1;
				line-height: 28rpx;
			}
		}

		.images {
			display: flex;
			flex-wrap: wrap;
			justify-content: space-between;
			margin: 20rpx 0;

			image {
				width: calc((100vw - 104rpx - 60rpx) /3);
				height: calc((100vw - 104rpx - 60rpx) /3);
				border-radius: 18rpx;
			}

			.i {
				width: calc((100vw - 104rpx - 60rpx) /3);
			}
		}

		.images:last-child {
			margin-bottom: 0;
		}
	}
</style>